package com.chen.mapper;

import com.chen.common.result.PageResult;
import com.chen.common.result.Result;
import com.chen.judge.codesandbox.model.JudgeResult;
import com.chen.popj.dto.ProblemPageQueryDTO;
import com.chen.popj.entity.ContestProblem;
import com.chen.popj.entity.Problem;
import com.chen.popj.entity.ProblemSubmit;
import com.chen.popj.vo.ProblemListVO;
import com.chen.popj.vo.ProblemVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface ProblemMapper {

    /**
     * 添加题目
     *
     * @param problem
     */
    void addProblem(Problem problem);

    /**
     * 题目分页查询
     *
     * @param problemPageQueryDTO
     * @return
     */
    Page<ProblemListVO> pageQuery(ProblemPageQueryDTO problemPageQueryDTO);

    /**
     * 根据题目id查询题目详情
     *
     * @param problemId
     * @return
     */
    @Select("select * from problem where id = ${problemId}")
    Problem queryProblem(Integer problemId);

    /**
     * 添加用户编写的题目代码
     *
     * @param problemSubmit
     */
    void problemSubmit(ProblemSubmit problemSubmit);

    /**
     * 根据题目id获取题目信息
     *
     * @param problemId
     * @return
     */
    @Select("select * from problem where id = #{problemId};")
    Problem getById(Integer problemId);

    /**
     * 根据提交id获取题目做题结果
     *
     * @param problemSubmitId
     * @return
     */
    @Select("select judge_info as judgeResult from problem_submit where id= #{problemSubmitId};")
    String getProblemResult(Integer problemSubmitId);

    /**
     * 根据题目id修改题目信息
     *
     * @param problem
     */
    void updateById(Problem problem);

    /**
     * 根据比赛的题目ids和比赛id查询题目
     *
     * @param contestProblemIds
     * @param contestId
     * @return
     */
    List<ContestProblem> queryProblemByContestIds(@Param("contestProblemIds") List<Integer> contestProblemIds, @Param("contestId") Integer contestId);

    /**
     * 根据题目id删除题目
     *
     * @param ids
     */
    void delete(ArrayList<Integer> ids);
}
